﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CarID
{
    public partial class Form1 : Form
    {
        string ImagePath; // 图片路径

        private OpenFileDialog openFileDialog1 = new OpenFileDialog();

        private HDevelopExport HD = new HDevelopExport();

        public Form1()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 加载图片的按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnLoadImage_Click(object sender, EventArgs e)
        {
            // 设置过滤文件条件
            openFileDialog1.Filter = "JPG文件|*.jpg";
            // 设置关闭对话回到当前目录
            openFileDialog1.RestoreDirectory = true;
            // 打开对话框
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                ImagePath = openFileDialog1.FileName;
                // 读取图片并显示到该窗口上面
                HD.ReadImage(hWindowControl1.HalconWindow, hWindowControl1.Width, hWindowControl1.Height, ImagePath);
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            var cardNumber = HD.RecognitionImage();
            this.textBox1.Text = this.textBox1.Text + cardNumber + "\r\n";
        }
    }
}
